<?php

namespace app\datacenter\model;

use app\BaseModel;

class Shop extends BaseModel
{
    protected $connection = 'iot';

    /**
     * 根据机器ID获取商户经纬度
     * @param string $mac_id
     * @return array
     */
    public static function getShopInfo(string $mac_id): array
    {
        $model = self::alias('s')
            ->field('s.*')
            ->where(['m.mac_id' => $mac_id])
            ->join('machine m', 'm.shop_id = s.id')
            ->find();
        return $model ? $model->toArray() : [];
    }

}